Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big endian support for BSP loader #1466

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

Xav101
Copy link
Contributor

@Xav101 Xav101 commented Oct 22, 2023

This set of patches seems like it's enough to get the game loading BSPs on big endian platforms. Tested on big endian mips-irix using half life 1 maps. This does not have support for extra lumps and doesn't support the QBSP2 files.

I probably missed something in here because there's quite a few fields in a BSP so please let me know if you notice anything.

@@ -337,6 +337,10 @@ static wfile_t *W_Open( const char *filename, int *error )
return NULL;
}

LittleLongSW(header.ident);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces in parentheses. :)
It's fine to not have them in type casts and between consequent parentheses, but they should be everywhere else:
For example:

(T *)(expr + (expression2 * n))

should be formatted as:

(T *)( expr + ( expression2 * n ))

Sorry, don't have clang-format for this yet, but we probably will migrate to something similar later.

@@ -303,7 +303,7 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
loaded = true;
break;
case Q1BSP_VERSION:
case HLBSP_VERSION:
case LittleLong(HLBSP_VERSION):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to change this:

uint32_t version;

version = LittleLong( *(uint *)buf );

So you don't have to add macro calls to every version check.

{
dheader_t *header = (dheader_t *)mod_base;
#ifdef XASH_BIG_ENDIAN
LittleLongSW( header->version );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're potentially writing to const here. While this memory isn't read-only, I'm not sure if it's a good solution here. I think we can remove const modifier from BSP model loader for now.

Also, you can use static inline instead of _inline. Or even just static, since most compilers do ignore inline keyword.

_inline is a legacy macro definition I forgot about, it's almost not used in new code.

@@ -1913,7 +1916,15 @@ static void Mod_LoadVertexes( dbspmodel_t *bmod )
{
if( bmod->isworld )
AddPointToBounds( in->point, world.mins, world.maxs );
#ifdef XASH_BIG_ENDIAN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may completely remove this check. Compiler will optimize out a loop that does nothing on little endian.

Also, if you didn't know, platform macros are defined into positive values in build.h, so they can be checked with just #if and used in complex expressions without defined() usage.

@@ -80,8 +80,9 @@ GNU General Public License for more details.
#define Q_round( x, y ) (floor( x / y + 0.5f ) * y )
#define Q_rint(x) ((x) < 0.0f ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))

#ifdef XASH_IRIX
#if defined( XASH_IRIX ) && defined( __GNUC__ )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. You can just use simple and readable #if XASH_IRIX && __GNUC__.

@a1batross
Copy link
Member

a1batross commented Oct 22, 2023

Also, your RTC battery seems worn out!

Xav101 added 14 commits 25 years ago

Though I don't care about commit date to be honest. But you still better rewrite the commits because the commit messages must be in a specific format:

tag: subtag: more subtags: short summary

long summary, if needed

You can easily rewrite commits using git rebase -i for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants